﻿/**
 * @author sminutoli
 */
import com.dinmax.flash.central.extension.shortcut.Shortcut
import com.dinmax.flash.utilities.xml.XMLUtils

class com.dinmax.flash.central.extension.shortcut.ShortcutFactory {
	
	public static function getShortcuts(doc:XMLNode):Array {
		var shortcuts:Array = new Array();
		
		if (doc.hasChildNodes()) {
			for (var aNode:XMLNode = doc.firstChild; aNode != null; aNode=aNode.nextSibling) {
				if (aNode.nodeType == 1) {
					var sCut:Shortcut = ShortcutFactory.getShortcut(aNode);
					shortcuts.push(sCut);
				};
			}; 
		}; // fin if
		//trace("ShortcutFactory.as getShortcuts() estoy devolviendo= "+shortcuts);
		return shortcuts;
	};
	
	private static function getShortcut(node:XMLNode):Shortcut {
		var sCut:Shortcut = new Shortcut();
		sCut.setId(Number(XMLUtils.getAttribute(node, "id")));
		sCut.setName(XMLUtils.getAttribute(node, "name"));
		sCut.setEmail(XMLUtils.getAttribute(node, "email"));
		sCut.setPhonenumber(Number(XMLUtils.getAttribute(node, "phonenumber")));
		if(XMLUtils.getAttribute(node, "isuser") == "true"){
			sCut.setIsuser(true);
		};
		return sCut;
	};
};
